<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<h:head>
		<title>Selezione Alloggi</title>
	</h:head>
	
	<h:body>
		<h:form>
			<p:dataTable id="accomodationTable" var="accomodation"
				value="#{accomodationBean.getFiltered(accomodationDialogBean.city)}" rows="10" paginator="true">
				<p:column headerText="Id">
					<h:outputText value="#{accomodation.id}" />
				</p:column>
	
				<p:column headerText="Nome">
					<h:outputText value="#{accomodation.name}" />
				</p:column>
	
				<p:column headerText="Città">
					<h:outputText value="#{accomodation.city}" />
				</p:column>
	
				<p:column headerText="Prezzo">
					<h:outputText value="#{accomodation.price}" />
				</p:column>

			<p:column headerText="Seleziona">
				<p:commandButton rendered="#{accomodationDialogBean.selected != accomodation.id}"
					value="Seleziona" action="#{accomodationDialogBean.select(accomodation)}" />
				<h:outputText rendered="#{accomodationDialogBean.selected == accomodation.id}"
					value="Selezionato" />
			</p:column>
		</p:dataTable>
		</h:form>
</h:body>

</html>